package main

import "fmt"

func main() {
	var input int32
	input = 111111111
	fmt.Printf("%0.32b\n", input)

	fmt.Println(numberOfLeadingZeros0(input))
}

func numberOfLeadingZeros0(input int32) int32 {
	if size := whichInt(input); input == 0 && size != 0 {
		return size
	}

	n := int32(1)
	if input>>16 == 0 {
		n += 16
		input = input << 16
	}
	if input>>24 == 0 {
		n += 8
		input = input << 8
	}
	if input>>28 == 0 {
		n += 4
		input = input << 4
	}
	if input>>30 == 0 {
		n += 2
		input = input << 2
	}
	n -= input >> 31
	return n
}

func whichInt(t interface{}) int32 {
	switch t.(type) {
	case int8:
		return 8
	case int16:
		return 16
	case int32:
		return 32
	case int64:
		return 64
	default:
		return 0
	}
}
